<template>
  <div>
    <div class="container">
      <el-form ref="query" :model="query" :inline="true" size="mini">
        <el-form-item label="跟踪号：" prop="bizTraceId">
          <el-input
              v-model="query.bizTraceId"
              placeholder="请填写跟踪号"
              clearable
          ></el-input>
        </el-form-item>

        <el-form-item label="IP：" prop="ip">
          <el-input
              v-model="query.ip"
              placeholder="请填写ip"
              clearable
          ></el-input>
        </el-form-item>

        <el-form-item label="模块名称：" prop="moduleName">
          <el-input
              v-model="query.moduleName"
              placeholder="请填写模块名称"
              clearable
          ></el-input>
        </el-form-item>

        <el-form-item label="手机：" prop="mobile">
        <el-input
            v-model="query.mobile"
            placeholder="请填写手机"
            clearable
        ></el-input>
        </el-form-item>

        <el-button size="mini" type="primary" icon="el-icon-search" @click="handleSearch"
        >搜索
        </el-button
        >
        <el-button size="mini" type="primary" icon="el-icon-delete" @click="handleClear"
        >清空
        </el-button
        >
      </el-form>

      <el-table
          :data="records"
          border
          class="table"
          ref="multipleTable"
          header-cell-class-name="table-header"
      >
        <el-table-column prop="bizTraceId" label="跟踪号"></el-table-column>
        <el-table-column prop="osName" label="系统名称"></el-table-column>
        <el-table-column prop="browserName" label="浏览器"></el-table-column>
        <el-table-column prop="ip" label="ip"></el-table-column>
        <el-table-column prop="province" label="所在省份"></el-table-column>
        <el-table-column prop="city" label="所在城市"></el-table-column>
        <el-table-column prop="moduleName" label="模块名称"></el-table-column>
        <el-table-column prop="moduleDesc" label="模块描述"></el-table-column>
        <el-table-column prop="mobile" label="手机"></el-table-column>
        <el-table-column prop="createdTime" label="创建时间"></el-table-column>
        <el-table-column label="操作" width="180" align="center">
          <template #default="scope">
            <el-button
                type="text"
                icon="el-icon-info"
                @click="handleInfo(scope.row.id)"
                v-if="$perm.hasPerm('button_loginLog_detail')"
            >详情
            </el-button
            >
          </template>
        </el-table-column>
      </el-table>
      <div class="pagination">
        <custom-page
            :current="query.current"
            :size="query.size"
            :total="total"
            @current-change="handlePageChange"
        />
      </div>
    </div>
  </div>
</template>

<script>
import {loginLogPageApi} from "../../api/log/loginLog";

export default {
  data() {
    return {
      query: {
        current: 1,
        size: 10,
        bizTraceId: null,
        ip: null,
        moduleName: null,
        mobile: null
      },
      records: [],
      multipleSelection: [],
      delList: [],
      editVisible: false,
      total: 0,
      form: {},
      idx: -1,
      id: -1,
    };
  },
  created() {
    this.getData();
  },
  methods: {
    // 获取数据
    getData() {
      loginLogPageApi(this.query).then((res) => {
        this.records = res?.bizData?.records;
        this.total = res?.bizData?.total;
      });
    },
    // 触发搜索按钮
    handleSearch() {
      this.query.current = 1;
      this.getData();
    },
    // 清空
    handleClear() {
      if (this.$refs.query != undefined) {
        this.$refs.query.resetFields();
        this.getData();
      }
    },
    // 详情操作
    handleInfo(id) {
      this.$router.goPage({
        path: "/login/log/detail",
        query: {
          id,
        },
      });
    },
    // 添加 编辑弹出层关闭动画结束操作
    closed() {
      this.idx = -1;
      this.form = deepCopy(obj);
    },
    // 分页导航
    handlePageChange(val) {
      this.query.current = val;
      this.getData();
    },
  },
};
</script>

<style scoped>
.handle-box {
  margin-bottom: 20px;
}

.handle-input {
  width: 300px;
  display: inline-block;
}

.table {
  width: 100%;
  font-size: 14px;
}

.red {
  color: #ff0000;
}

.mr10 {
  margin-right: 10px;
}

.table-td-thumb {
  display: block;
  margin: auto;
  width: 40px;
  height: 40px;
}
</style>
